//
//  YZMAppStyle.m
//  YZMicroStock
//
//  Created by wangminhong on 16/3/21.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZMAppStyle.h"
#import <ColorUtils/ColorUtils.h>
#import <Masonry/Masonry.h>
#import "YZMNavigationController.h"
#import "YZMControllerManager.h"
#import "UIImage+Utils.h"
#import "YZMBankCardModel.h"

#import <objc/runtime.h>

@implementation YZMAppStyle

+ (void)customAppApearance
{
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent];
    [[UINavigationBar appearance] setBackgroundImage:[self barBackgroundImage] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setTitleTextAttributes: @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName:[YZMAppStyle largeSizeFont]}];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    [[UINavigationBar appearance] setBackIndicatorImage: [[UIImage alloc] init]];
    [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[[UIImage alloc] init]];
    [[UITabBar appearance] setTintColor: [self colorForIconColor]];
    [[UITabBar appearance] setBackgroundImage:[self tabbarBackgroundImage]];
//    UIOffset offset = {};
//    offset.horizontal = -10000;
    UIBarButtonItem *appearanceItem = [UIBarButtonItem appearance];
//    [appearanceItem setBackButtonTitlePositionAdjustment: offset forBarMetrics:UIBarMetricsDefault];
    UIImage *backImage = [[[self barBackImage] resizableImageWithCapInsets: UIEdgeInsetsMake(1, 32, 1, 1)]  imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
    [appearanceItem setBackButtonBackgroundImage: backImage forState: UIControlStateNormal barMetrics:UIBarMetricsDefault];
}

#pragma mark - colors

#ifdef YZMicroStock

+ (UIColor *)appBackgroundColor{
    
    return [UIColor colorWithString:@"#0E1821"];
}

+(UIColor *)colorForMain{
    
    return [UIColor colorWithString:@"#121C25"];
}

+ (UIColor *)colorForBarBGColor{
    
    return [self colorForMain];
}

+ (UIColor *)colorForMainTextColor{
    
    return [self colorForWhite];
}

+ (UIColor *)colorForSplitLine{
    
    return [UIColor colorWithString:@"#1C262F"];
}

+ (UIColor *)tabbarBackgroundColor{
    
    return [UIColor colorWithString:@"#131E29"];
}

+ (UIColor *)colorForIconColor{
    
    return [UIColor colorWithString:@"#FFD900"];
}

+(UIColor *)colorForSpreadBg{
    
    return [UIColor colorWithString:@"#162637"];
}

+(UIColor *)buttonSelectedColor{
    
    return [self colorForYellowButton];
}

+(UIColor *)colorForbuttonLineColor{
    
    return [UIColor colorWithString:@"#242D35"];
}

+ (UIColor *)colorForDropText{
    
    return [UIColor colorWithString:@"#41FFAD"];
}

#else

+ (UIColor *)appBackgroundColor{
    
    return [UIColor colorWithString:@"#F4F4F4"];
}

+(UIColor *)colorForMain{
    
    return [UIColor colorWithString:@"#FDFDFD"];
}

+ (UIColor *)colorForBarBGColor{
    
    return [UIColor colorWithString:@"#4962B3"];
}

+ (UIColor *)colorForMainTextColor{
    
    return [self colorForBlackText];
}

+ (UIColor *)colorForSplitLine{
    
    return [self colorForLine];
}

+ (UIColor *)tabbarBackgroundColor{
    
    return [self colorForWhite];
}

+ (UIColor *)colorForIconColor{
    
    return [self colorForBarBGColor];
}

+(UIColor *)colorForSpreadBg{
    
    return [self appBackgroundColor];
}

+(UIColor *)buttonSelectedColor{
    
    return [self colorForBarBGColor];
}

+(UIColor *)colorForbuttonLineColor{
    
    return [self colorForLine];
}

+ (UIColor *)colorForDropText{
    
    return [UIColor colorWithString:@"#01B2BE"];
}

+ (UIColor *)colorForBoder {
    return [UIColor colorWithString:@"#979797"];
}
#endif

+ (UIColor *)colorForBoder {
    return [UIColor colorWithString:@"#979797"];
}

+ (UIColor *)colorForgray{
    
    return [UIColor colorWithString: @"#E2E2E2"];
}

+ (UIColor *)colorForLine{
    
    return [UIColor colorWithString: @"#ECECEC"];
}

//虚线颜色
+ (UIColor *)colorForSeparatorLine{
    return [UIColor colorWithString:@"#3D91EB"];
}

+ (UIColor *)colorForRiseText{
    
    return [UIColor colorWithString:@"#E8003F"];
}


+ (UIColor *)colorForBlueText{
    
    return [UIColor colorWithString:@"#49A7F6"];
}

+ (UIColor *)colorForBlackText
{
    return [UIColor colorWithString: @"#333333"];
}

+ (UIColor *)colorForRedText
{
    return [UIColor colorWithRed:204 / 255.0 green:51 / 255.0 blue:102 / 255.0 alpha:1.0];
}

+ (UIColor *)colorForGrayText{
    
    return [UIColor colorWithString: @"#666666"];
}

+ (UIColor *)colorForLightGrayText{
    
    return [UIColor colorWithString: @"#999999"];
}

+ (UIColor *)colorForGrayUnable{
    
    return [UIColor colorWithString:@"#CCCCCC"];
}


+ (UIColor *)colorForWhite
{
    return [UIColor colorWithString:@"FFFFFF"];
}

+ (UIColor *)colorForHighted{
    return [UIColor colorWithString:@"#B7B8BC"];
}

+ (UIColor *)colorForLightBlueText {
    
    return [UIColor colorWithString:@"#3183E8"];
}

+ (UIColor *)colorForBankRed {
    
    return [UIColor colorWithString:@"#E47070"];
}

+ (UIColor *)colorForLightWhite {
    
    return [UIColor colorWithString:@"#F9F9F9"];
}

+ (UIColor *)colorForString:(NSString *)string {
    
    return [UIColor colorWithString:string];
}

+ (void)colorWithView:(UIView *)view withLayer:(CAGradientLayer *)layer withColorArray:(NSArray *)array {
    
    layer.frame = view.bounds;
    //设置渐变区域的起始和终止位置（范围为0-1）
    layer.startPoint = CGPointMake(0, 0);
    layer.endPoint = CGPointMake(0, 1);
    
    //设置颜色数组
    layer.colors = array;
    
    //设置颜色分割点（范围：0-1）
    layer.locations = @[@(0.0f), @(1.0f)];
}

#pragma mark - fonts
+ (UIFont *)fontWithSize:(float)size{
    
    return [UIFont systemFontOfSize: size];
}

+ (UIFont *)boldFontWithSize:(float)size{
    
    return [UIFont boldSystemFontOfSize: size];
}

//提示等大号字体
+ (UIFont *)largeSizeBoldFont
{
    return [UIFont boldSystemFontOfSize: 17];
}

+ (UIFont *)largeSizeFont
{
    return [UIFont systemFontOfSize: 17];
}

+ (UIFont *)mediumSizeBoldFont
{
    return [UIFont boldSystemFontOfSize: 14];
}

+ (UIFont *)mediumSizeFont
{
    return [UIFont systemFontOfSize: 14];
}

+ (UIFont *)smallSizeBoldFont{
    
    return [UIFont boldSystemFontOfSize: 12];
}

+ (UIFont *)smallSizeFont
{
    return [UIFont systemFontOfSize: 12];
}

+ (UIFont *)bigSizeFont
{
    return [UIFont systemFontOfSize: 40];
}

#pragma mark - labels


+ (UILabel *)labelWithFont:(UIFont *)font andColor:(UIColor *)color{
    
    UILabel *label = [UILabel new];
    label.font = font;
    label.textColor = color;
    return label;
}

+ (UILabel *)labelWithLargeBlack
{
    return [self labelWithFont:[self largeSizeFont] andColor:[self colorForBlackText]];
}

+ (UILabel *)labelWithMediumGray
{
    return [self labelWithFont:[self mediumSizeFont] andColor:[self colorForGrayText]];
}

+ (UILabel *)labelWithSmallLightGray{
    
    return [self labelWithFont:[self smallSizeFont] andColor:[self colorForLightGrayText]];
}

+ (UILabel *)labelWithMediumLightGray {
    
    return [self labelWithFont:[self mediumSizeFont] andColor:[self colorForLightGrayText]];
}

+ (UILabel *)labelWithLargeLightGray {
    
    return [self labelWithFont:[self largeSizeFont] andColor:[self colorForLightGrayText]];
}

+ (UILabel *)labelWithWhite
{
    return [self labelWithFont:[self largeSizeFont] andColor:[self colorForMainTextColor]];
}

+ (UILabel *)labelWithGigWhite
{
    return [self labelWithFont:[self bigSizeFont] andColor:[self colorForMainTextColor]];
}

+ (UILabel *)labelWithLargeGray
{
    return [self labelWithFont:[self largeSizeFont] andColor:[self colorForGrayText]];
}

+ (UILabel *)labelWithMediumBlack
{
    return [self labelWithFont:[self mediumSizeFont] andColor:[self colorForBlackText]];
}

+ (UILabel *)labelWithMediumRise{
    return [self labelWithFont:[self mediumSizeFont] andColor:[self colorForRiseText]];
}

+ (UILabel *)labelWithSmallGray {
    
    return [self labelWithFont:[self smallSizeFont] andColor:[self colorForGrayText]];
}

+ (UILabel *)labelWithLargeWhite {
    
    return [self labelWithFont:[self largeSizeFont] andColor:[self colorForMainTextColor]];
}

+ (UILabel *)labelWithMediumWhite {
    
    return [self labelWithFont:[self mediumSizeFont] andColor:[self colorForMainTextColor]];
}

+ (UILabel *)labelWithSmallWhite {
    
    return [self labelWithFont:[self smallSizeFont] andColor:[self colorForMainTextColor]];
}

+ (UILabel *)labelWithSmallYellow {
    
    return [self labelWithFont:[self smallSizeFont] andColor:[self colorForIconColor]];
}

+ (UILabel *)labelWithLargeYellow {
    
    return [self labelWithFont:[self largeSizeFont] andColor:[self colorForIconColor]];
}

#pragma mark - view

+ (UIView *)splitLine{
    
    UIView *line = [UIView new];
    line.backgroundColor = [YZMAppStyle colorForSplitLine];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
    }];
    
    return line;
}

+ (UIView *)grayUnableLine {
    
    UIView *line = [UIView new];
    line.backgroundColor = [YZMAppStyle colorForGrayUnable];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(3);
    }];
    
    return line;
}

#pragma mark - buttons

+ (UIButton *)explainButton
{
    UIButton *explainButton = [UIButton buttonWithType: UIButtonTypeCustom];
    [explainButton setBackgroundColor:[UIColor clearColor]];
    [explainButton setImage:[UIImage imageNamed:@"icon_explain_button"] forState:UIControlStateNormal];
    [explainButton setImageEdgeInsets:UIEdgeInsetsMake(6, 6, 6, 6)];
    [explainButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
    }];
    
    return explainButton;
}

+ (UIButton *)submitButton{
    
    UIButton *submitBT = [UIButton new];
    [YZMSetBorderAndCornerRadius setView:submitBT borderWidth:0 borderColor:nil cornerRadius:3.0];
    submitBT.backgroundColor = [YZMAppStyle buttonSelectedColor];
    [submitBT setBackgroundImage:[UIImage createImageWithColor:[YZMAppStyle colorForGrayUnable]] forState:UIControlStateDisabled];
    [submitBT setTitleColor:[YZMAppStyle colorForLightGrayText] forState:UIControlStateDisabled];
    [submitBT setTitleColor:[YZMAppStyle appBackgroundColor] forState:UIControlStateNormal];
    [submitBT.titleLabel setFont:[YZMAppStyle largeSizeFont]];
    submitBT.enabled = NO;
    [submitBT mas_makeConstraints:^(MASConstraintMaker *maker){
        
        maker.height.mas_equalTo(44);
    }];
    
    return submitBT;
}

+ (UIButton *)regButton {
    
    UIButton *regBT = [UIButton new];
    regBT.clipsToBounds = YES;
    regBT.layer.cornerRadius = 3.0;
    regBT.layer.borderWidth = 1;
    regBT.layer.borderColor = [YZMAppStyle colorForWhite].CGColor;
    regBT.layer.masksToBounds = YES;
    [regBT setBackgroundImage:[UIImage createImageWithColor:[YZMAppStyle colorForGrayUnable]] forState:UIControlStateDisabled];
    [regBT setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [regBT.titleLabel setFont:[YZMAppStyle largeSizeFont]];
    
    return regBT;
}

#pragma mark - images

+ (UIImage *)barBackgroundImage
{
    UIGraphicsBeginImageContextWithOptions(CGSizeMake([UIScreen mainScreen].bounds.size.width, 64), NO, [UIScreen mainScreen].scale);
    
    [[YZMAppStyle colorForBarBGColor] setFill];
    CGContextFillRect(UIGraphicsGetCurrentContext(),  CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64));
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

+ (UIImage *)tabbarBackgroundImage
{
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(10, 49), NO, [UIScreen mainScreen].scale);
    
    [[YZMAppStyle tabbarBackgroundColor] setFill];
    CGContextFillRect(UIGraphicsGetCurrentContext(),  CGRectMake(0, 0, 10, 49));
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

+ (UIImage *)barBackImage
{
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(32, 32), NO, [UIScreen mainScreen].scale);
    
    UIImage *backImage = [UIImage imageNamed: @"icon_white_back"];
    [backImage drawInRect: CGRectMake(6, 7,  20, 20)];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

#pragma mark - bar items

+ (CGSize)sizeOfString: (NSString *)str font: (UIFont *)font
{
    return [str sizeWithAttributes: @{NSFontAttributeName: font}];
}

+ (UIBarButtonItem *)leftBarItemWithTitle: (NSString *)title target: (id)target action: (SEL)selector
{
    UIFont *barItemFont = [UIFont boldSystemFontOfSize: 14];
    CGFloat quickLength = [self sizeOfString: title font: barItemFont].width;
    NSInteger offset = 8;
    UIView *contentView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, quickLength+offset, 44)];
    UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
    button.frame = CGRectMake(offset, 0, quickLength, 44);
    button.titleLabel.font = barItemFont;
    [button setTitle: title forState: UIControlStateNormal];
    [button addTarget: target action: selector forControlEvents: UIControlEventTouchUpInside];
    [contentView addSubview: button];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView: contentView];
    return item;
}

+ (UIBarButtonItem *)leftBarItemWithImage: (NSString *)imageName target: (id)target action: (SEL)selector
{
    UIImage *image = [UIImage imageNamed: imageName];
    CGFloat quickLength = image.size.width;
    NSInteger offset = 0;
    UIView *contentView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, quickLength+offset, 44)];

    UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
    button.frame = CGRectMake(offset, 0, quickLength, 44);
    [button setImage:image forState: UIControlStateNormal];
    [button addTarget: target action: selector forControlEvents: UIControlEventTouchUpInside];
    [contentView addSubview: button];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView: contentView];
    return item;
}

+ (UIBarButtonItem *)rightBarItemWithTitle: (NSString *)title target: (id)target action: (SEL)selector;
{
    UIFont *barItemFont = [UIFont boldSystemFontOfSize: 14];
    CGFloat quickLength = [self sizeOfString: title font: barItemFont].width;
    UIView *contentView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, quickLength+8, 44)];
    UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
    button.frame = CGRectMake(8, 0, quickLength, 44);
    button.titleLabel.font = barItemFont;
    [button setTitle: title forState: UIControlStateNormal];
    [button addTarget: target action: selector forControlEvents: UIControlEventTouchUpInside];
    [contentView addSubview: button];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView: contentView];
    return item;
}

+ (UIBarButtonItem *)rightBarItemWithImage: (NSString *)imageName target: (id)target action: (SEL)selector;
{
    UIImage *image = [UIImage imageNamed:imageName];
    CGFloat quickLength = image.size.width;
    NSInteger offset = 0;
    UIView *contentView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, quickLength+offset, 44)];
    UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, quickLength, 44);
    [button setImage:image forState:UIControlStateNormal];
    [button addTarget: target action: selector forControlEvents: UIControlEventTouchUpInside];
    [contentView addSubview: button];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView: contentView];
    return item;
}

+ (UITextField *)inputTextField {
    
    UITextField *inputTF = [[UITextField alloc] init];
    inputTF.placeholder = @" ";
    inputTF.textColor = [YZMAppStyle colorForMainTextColor];
    [inputTF setValue:[YZMAppStyle colorForGrayText] forKeyPath:@"_placeholderLabel.textColor"];
    [inputTF setValue:[YZMAppStyle mediumSizeFont] forKeyPath:@"_placeholderLabel.font"];
    inputTF.font = [YZMAppStyle mediumSizeFont];
    inputTF.clearButtonMode = UITextFieldViewModeWhileEditing;
    return inputTF;
}

#pragma mark -- V2.3color

+ (UIColor *)colorForYellowButton
{
    return [UIColor colorWithString:@"#EDBD00"];
}

+(UIColor *)colorForRedMark
{
    return [UIColor colorWithString:@"#DB4E54"];
}

+(UIColor *)colorForLabelMark{
    
    return [UIColor colorWithString:@"#131E29"];
}


+ (UILabel *)labelWithRedBGAndWhiteFont;
{
    UILabel *label = [YZMAppStyle labelWithSmallWhite];
#ifndef  YZMicroStock
    label.textColor = [YZMAppStyle colorForWhite];
#endif
    label.backgroundColor = [self colorForRiseText];
    label.textAlignment = NSTextAlignmentCenter;
    label.layer.cornerRadius = 3;
    label.layer.masksToBounds = YES;
    return label;
}

+ (UILabel *)labelWithBuyWay;
{
    UILabel *label = [YZMAppStyle labelWithSmallYellow];
    label.layer.borderColor = [self colorForIconColor].CGColor;
    label.layer.borderWidth = 1;
    label.textAlignment = NSTextAlignmentCenter;
    label.layer.cornerRadius = 2;
    label.layer.masksToBounds = YES;
    return label;
}

+ (UIButton *)chooseDateBtn {
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitleColor:[YZMAppStyle colorForIconColor] forState:UIControlStateNormal];
    [btn setTitleColor:[YZMAppStyle colorForMain] forState:UIControlStateSelected];
    btn.titleLabel.font = [YZMAppStyle largeSizeFont];
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = [YZMAppStyle colorForIconColor].CGColor;
    btn.layer.masksToBounds = YES;
    btn.layer.cornerRadius = 2;
    [btn setBackgroundImage:[UIImage createImageWithColor:[YZMAppStyle colorForYellowButton]] forState:UIControlStateSelected];
    
    return btn;
}

#pragma mark -- 2017.1 newAdd

+(UIColor *)colorForstar{
    
    return [UIColor colorWithString:@"#FFF4C6"];
}

+ (UIColor *)colorForSpreadText{
    
    return [UIColor colorWithString: @"#FE6900"];
}


+(UIColor *)colorForInputLineColor{
    
    return [UIColor colorWithString:@"#5A6167"];
}

+(UIColor *)colorForDetailTextYellow{
    
    return [UIColor colorWithString:@"#FFF500"];
}

+(UILabel *)labelForSpreadDetailWithFont:(UIFont *)font andColor:(UIColor *)color{
    
    UILabel *label = [UILabel new];
    label.font = font;
    label.textAlignment=NSTextAlignmentCenter;
    label.textColor = color;
    return label;
}

+ (UIButton *)NewsubmitButton{
    
    UIButton *submitBT = [UIButton new];
    submitBT.clipsToBounds = YES;
    submitBT.layer.cornerRadius = 3.0;
    submitBT.layer.masksToBounds = YES;
    submitBT.backgroundColor = [YZMAppStyle buttonSelectedColor];
    [submitBT setBackgroundImage:[UIImage createImageWithColor:[YZMAppStyle appBackgroundColor]] forState:UIControlStateDisabled];
    
    submitBT.layer.borderWidth=1.0;
    submitBT.layer.borderColor=[YZMAppStyle colorForbuttonLineColor].CGColor;
    
    [submitBT setTitleColor:[YZMAppStyle colorForGrayText] forState:UIControlStateDisabled];
    [submitBT setTitleColor:[YZMAppStyle appBackgroundColor] forState:UIControlStateNormal];
    [submitBT.titleLabel setFont:[YZMAppStyle largeSizeFont]];
    submitBT.enabled = NO;
    [submitBT mas_makeConstraints:^(MASConstraintMaker *maker){
        
        maker.height.mas_equalTo(44);
    }];
    
    return submitBT;
}

#pragma mark v2.5
+(UIColor *)trendColorSecond{
    
    return [UIColor colorWithString:@"#4E72DB"];
}

+(UIColor *)trendColorThird{
    
    return [UIColor colorWithString:@"DB9B4E"];
}

#pragma mark -- NSMutableAttributedString

+(NSMutableAttributedString *)AttributedAndStr:(NSString *)content andAttributeStyle:(NSArray *)styleArr {
    
    if (content.length == 0) {
        
        return nil;
    }
    
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:content];
    
    for (NSDictionary *dic in styleArr) {
        
        NSRange range = [dic[@"range"] rangeValue];
        //判断range是否是一个有效值
        NSInteger len = range.length + range.location;
        if (content.length >= len) {
            
            if (dic[@"font"]) {
                
                [str addAttribute:NSFontAttributeName value:dic[@"font"] range:range];
            }
            
            if (dic[@"color"]) {
                
                [str addAttribute:NSForegroundColorAttributeName value:dic[@"color"] range:range];
            }
        }
    }
    
    return str;
}

+(UIColor *)colorforLineAvailMoney{
    
    return [UIColor colorWithString:@"#D8D8D8"];
}

+ (UIColor *)colorForLineOfCell{
    return [UIColor colorWithString:@"#1C262F"];
}

+ (void)addLineViewWithParentView:(id)iv color:(UIColor *)color{
    if (iv != nil) {
        UIView *viewLine = [[UIView alloc] init];
        if (color  == nil) {
            color = [self colorForLine];
        }
        viewLine.backgroundColor = color;
        [iv addSubview:viewLine];
        [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(iv);
            make.height.equalTo(@0.5);
        }];
    }
}

+ (void)addLeftLineViewWithParentView:(id)iv color:(UIColor *)color{
    if (iv != nil) {
        UIView *viewLine = [[UIView alloc] init];
        if (color  == nil) {
            color = [self colorForLine];
        }
        viewLine.backgroundColor = color;
        [iv addSubview:viewLine];
        [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(iv);
            make.width.equalTo(@0.5);
        }];
    }
}


+ (void)addTopLineViewWithParentView:(id)iv color:(UIColor *)color{
    if (iv != nil) {
        UIView *viewLine = [[UIView alloc] init];
        if (color  == nil) {
            color = [self colorForLine];
        }
        viewLine.backgroundColor = color;
        [iv addSubview:viewLine];
        [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(iv);
            make.height.equalTo(@0.5);
        }];
    }
}

@end
